This page last changed on Nov 21, 2005 by cholmes.
Summary
A WFS has the ability to lock features to prevent more than one person from updating the feature at one time.
Here's a set of possible actions that might occur if Person A and Person B are editing a dataset using a WFS:
1. Person A grabs a lock on a set of feature - "Delaware" and "Idaho"
2. If Person B tries to grab a lock on either of these features, an error will occur
3. If Person B tries to update these features, an error will occur
4. Person A can update the features and release the lock
5. Now, Person B can lock (and update) the features
Details
The WFS locking scheme is very simple, but there are several subtle issue involving when the locks are released:
1. Whenever you do a transaction on a locked feature, it becomes unlocked
2. If you set releaseAction="ALL" (the default), then ALL features associated with that lockID will be released after the transaction
3. If you set releaseAction="SOME", then only the features you touched during the transaction will be released, the others will remain locked
4. If you mention a LockID in your transaction, then you must have a lock on all the features touched by that transaction or you'll get an error. This causes people a lot of problems.
These are described in more detail below.
Examples (Using default Geoserver Install)
NOTE: You will get a different LockID than I do when you run these commands. Please replace the LockID in these transactions with the one the server returns to you.
Get a lock on "Delaware" and "Idaho"
<wfs:GetFeatureWithLock service="WFS" version="1.0.0"
outputFormat="GML2"
xmlns:topp="http:
xmlns:wfs="http:
xmlns:ogc="http:
xmlns:xsi="http:
xsi:schemaLocation="http: http: <Query typeName="topp:states">
<Filter>
<Or>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Delaware</Literal>
</PropertyIsEqualTo>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Idaho</Literal>
</PropertyIsEqualTo>
</Or>
</Filter>
</Query>
</wfs:GetFeatureWithLock>
NOTE: you will get a lockID back from this response (its right at the top in the "<wfs:FeatureCollection>" element. Remember this.
Try to update the feature. This will fail because you do not own the lock.
<wfs:Transaction service="WFS" version="1.0.0"
xmlns:topp="http:
xmlns:ogc="http:
xmlns:wfs="http:>
<wfs:Update typeName="topp:states">
<wfs:Property>
<wfs:Name>MALE</wfs:Name>
<wfs:Value>-999999</wfs:Value>
</wfs:Property>
<ogc:Filter>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Delaware</Literal>
</PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
This time mention the lockId you got from above (replace with what you got)
NOTE: in this case we did not specify a releaseAction, so it defaults to "ALL". In this case, both locks are released.
<wfs:Transaction service="WFS" version="1.0.0"
xmlns:topp="http:
xmlns:ogc="http:
xmlns:wfs="http:>
<wfs:LockId>GeoServer_4d1d517227455c58</wfs:LockId>
<wfs:Update typeName="topp:states">
<wfs:Property>
<wfs:Name>MALE</wfs:Name>
<wfs:Value>-999999</wfs:Value>
</wfs:Property>
<ogc:Filter>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Delaware</Literal>
</PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
This transaction will fail because the lock has been released by the previous transaction.
NOTE: even though the row is no longer locked, because you mention a lockid the row must be locked.
<wfs:Transaction service="WFS" version="1.0.0"
xmlns:topp="http:
xmlns:ogc="http:
xmlns:wfs="http:>
<wfs:LockId>GeoServer_4d1d517227455c58</wfs:LockId>
<wfs:Update typeName="topp:states">
<wfs:Property>
<wfs:Name>MALE</wfs:Name>
<wfs:Value>-1234</wfs:Value>
</wfs:Property>
<ogc:Filter>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Delaware</Literal>
</PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
This transaction works because the row is not locked and you have not mentioned a lockid.
<wfs:Transaction service="WFS" version="1.0.0"
xmlns:topp="http:
xmlns:ogc="http:
xmlns:wfs="http:>
<wfs:Update typeName="topp:states">
<wfs:Property>
<wfs:Name>MALE</wfs:Name>
<wfs:Value>-7890</wfs:Value>
</wfs:Property>
<ogc:Filter>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Delaware</Literal>
</PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
Please re-execute the GetFeatureWithLock and get the two rows locked.
NOTE: this time we set the releaseAction to "SOME". At the end of this transaction, the Delaware lock is released, but the Idaho lock remains.
<wfs:Transaction service="WFS" version="1.0.0"
xmlns:topp="http:
xmlns:ogc="http:
xmlns:wfs="http:
releaseAction="SOME">
<wfs:LockId>GeoServer_6de22372276223da</wfs:LockId>
<wfs:Update typeName="topp:states">
<wfs:Property>
<wfs:Name>MALE</wfs:Name>
<wfs:Value>-999999</wfs:Value>
</wfs:Property>
<ogc:Filter>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Delaware</Literal>
</PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
LockFeature Examples
An alternative way of locking a feature is to use LockFeature. Its almost exactly the same as GetFeatureWithLock, but it doesnt return the actual features. For example,
<wfs:LockFeature service="WFS" version="1.0.0"
outputFormat="GML2"
xmlns:topp="http:
xmlns:wfs="http:
xmlns:ogc="http:
xmlns:xsi="http:
xsi:schemaLocation="http: http: <Lock typeName="topp:states">
<Filter>
<Or>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Delaware</Literal>
</PropertyIsEqualTo>
<PropertyIsEqualTo>
<PropertyName>STATE_NAME</PropertyName>
<Literal>Idaho</Literal>
</PropertyIsEqualTo>
</Or>
</Filter>
</Lock>
</wfs:LockFeature>
returns:
<?xml version="1.0" encoding="UTF-8"?>
<WFS_LockFeatureResponse xmlns="http:
xmlns:xsi="http:
xsi:schemaLocation="http:http:
<LockId>GeoServer_218172b636a740c3</LockId>
</WFS_LockFeatureResponse>
Help make this page better
This page is in a Wiki - that means that you, the reader, can modify the content to make it better. If you can improve this page, please press the "Edit Page" link on the top right.
|